//
//  ZH_HomeScheduleViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/30.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_HomeScheduleViewController.h"
#import "ZH_ScheduleTableViewCell.h"
#import "LXCalender.h"
#import "UIColor+Expanded.h"
#import "ZH_ClassViewModel.h"
@interface ZH_HomeScheduleViewController ()<UITableViewDataSource,UITableViewDelegate>
//tableView
@property (nonatomic,weak)UITableView *tableView;
@property(nonatomic,strong)LXCalendarView *calenderView;
@property (nonatomic,strong)ZH_ClassViewModel *viewModel;
@end

@implementation ZH_HomeScheduleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
    [self initData];
}
- (void)cleanUpData{
    [self setViewModel:nil];
}
- (void)initData{
    if(self.idString.length > 0){
        [self.viewModel.dateParam setObject:self.idString forKey:@"id"];
        WEAKSelf;
        [self.viewModel dateListResultBlock:^(NSString *code, NSString *message, id data) {
            if ([code isEqualToString:@"0"]) {
                
            }
            else{
                if ([code isEqualToString:@"1002"]) {
                    [self showHint:@"登录过期"];
                }
                else{
                    [weakSelf showHint:message];
                }
            }
        }];
    }
}
- (void)initUserInterface{
    self.navigationItem.title = @"我的课表";
    self.calenderView =[[LXCalendarView alloc]initWithFrame:CGRectMake(20, 0, kMainScreenWidth - 40, 0)];
    
    self.calenderView.currentMonthTitleColor =[UIColor hexStringToColor:@"2c2c2c"];
    self.calenderView.lastMonthTitleColor =[UIColor hexStringToColor:@"8a8a8a"];
    self.calenderView.nextMonthTitleColor =[UIColor hexStringToColor:@"8a8a8a"];
    
    self.calenderView.isHaveAnimation = YES;
    
    self.calenderView.isCanScroll = NO;
    
    self.calenderView.isShowLastAndNextBtn = YES;
    
    self.calenderView.isShowLastAndNextDate = YES;
    
    self.calenderView.todayTitleColor =[UIColor purpleColor];
    
    self.calenderView.selectBackColor =[UIColor blueColor];
    
    self.calenderView.backgroundColor =[UIColor whiteColor];
    
    
    [self.calenderView dealData];
    
    [self.view addSubview:self.calenderView];
    
    
    
    self.calenderView.selectBlock = ^(NSInteger year, NSInteger month, NSInteger day) {
        NSLog(@"%ld年 - %ld月 - %ld日",year,month,day);
    };

    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.calenderView.mas_bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
}
#pragma mark - UITableViewDataSource,UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return FITSCALE(45);
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
//    UIView *view = [UIView createViewWithBackgroundColor:kFontColorWhite];
//    UILabel *leftLabel = [UILabel createLabelWithText:@"8月1日" font:kFontSize_24];
//    leftLabel.textColor = [UIColor colorWithHexString:@"#00C9AE"];
//    [view addSubview:leftLabel];
//    [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(view);
//        make.left.equalTo(view).offset(FITSCALE(22));
//    }];
//    UILabel *centerLabel = [UILabel createLabelWithText:@"今日课程" font:kFontSize_30];
//    [view addSubview:centerLabel];
//    [centerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.center.equalTo(view);
//    }];
//    return view;
    return nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ZH_ScheduleTableViewCell *cell = [ZH_ScheduleTableViewCell cellWithTableView:tableView];
    return cell;
}
#pragma mark - getter,setter
- (UITableView *)tableView{
    if (!_tableView) {
        UITableView *tableView = [UITableView createTableViewWithDelegateTarget:self];
        tableView.backgroundColor = kCommonBackgroudColor;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [tableView setCellAutoAdaptationForEstimatedRowHeight:FITSCALE(100)];
        [self.view addSubview:_tableView = tableView];
    }
    return _tableView;
}
- (ZH_ClassViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[ZH_ClassViewModel alloc] init];
    }
    return _viewModel;
}
@end
